import { DomUtils } from '../utils/DomUtilsMin';


export class Bing {
    
    static hostname = 'cn.bing.com';

    main() {
        DomUtils.remove([
            '#tallhead',
            '#b_footer',
            '#b_results>.b_msg',
            '.cn_related_search_upsell_container',
            '.rslist_title'
        ]);
        DomUtils.observe(document.body, ['childList'], { childList: true }, ({ target, observer }) => {
            target.querySelector('#b_footer')?.remove();
            target.querySelector('#results_removed')?.parentElement.remove();
            target.querySelector('#b_pag_sh_btn_container')?.remove();
            // 页面底部的 Bing 广告
            target.querySelector('.cn_related_search_upsell_container')?.remove();
            // 删除相关搜索
            Array.from(target.querySelectorAll('#b_results h2'))
                .find(item => item.textContent === '相关搜索')
                ?.parentElement
                ?.parentElement
                ?.remove();
        });
        // 删除 "其他用户搜索"
        DomUtils.observe('#b_results', ['childList'], { childList: true }, ({ target }) => {
            target.querySelector('.rslist_title')
                ?.parentElement
                ?.parentElement
                ?.parentElement
                ?.remove();
        });
    }
}